package dao.impl;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;


import vo.Commodity;
import dao.CommodityDao;

@Repository("commodityDao")
public class CommodityDaoImpl implements CommodityDao {
	@Autowired(required=true)
	@PersistenceContext(name="un")
	private EntityManager em;

	@Override
	public List<Commodity> findAllCommodity() {
		String jpql = "select c from Commodity c";
		@SuppressWarnings("unchecked")
		List<Commodity> commodity_list = em.createQuery(jpql).getResultList();
		em.close();
		return commodity_list;
	}

	@Override
	public Commodity findAllCommodityById(String commodityId) {
		// TODO Auto-generated method stub
		return null;
	}

}
